
package com.ce.yw.leaveflow.logic.search;

import java.sql.ResultSet;
import java.sql.SQLException;
import com.ce.yw.leaveflow.view.OaLeaveView;
import com.ce.framework.datamaintain.logic.ISQLMapper;
import com.ce.framework.datamaintain.logic.SQLSearchCondition;
import com.ce.framework.exception.AppException;
import com.ce.framework.util.StringUtil;

/**
* 嫦娥软件有限公司 版权所有 2013
* 创建人：　张波
* 创建日期：2014-01-27
* 创建时间：14:17:44
* 功能描述：请假 [OA_LEAVE]条件过滤类
* ==============================================
* 修改历史
* 修改人		修改时间		修改原因
*
* ==============================================
*/
@SuppressWarnings("rawtypes")
public class OaLeaveSearchCondition  extends SQLSearchCondition
	implements ISQLMapper
{
    
	private String userId;
	private String InTaskIds;
	private String status;
	public String getSearchSql() throws AppException {
		
		StringBuffer sql = new StringBuffer("select t.*,p.vc_name as user_name from oa_leave t,sys_t_person p where t.user_id=p.vc_id(+) and t.VC_DEL$FLAG = 0");
		//有待办任务
		if(StringUtil.isNotBlank(InTaskIds)){
			sql.append(" and t.vc_id in "+InTaskIds);
		}
		if(StringUtil.isNotBlank(userId)){
			sql.append(" and t.user_id='"+userId+"'");
		}
		if(StringUtil.isNotBlank(status)){
			sql.append(" and t.status>"+status);
		}
		/*=========自行修改该处代码================
		//实现排序的代码
		sql.append(" "+super.getOrderBy());
		======================================*/
		return sql.toString();
	}
	
	public Object fromSQLQuery(ResultSet rs, int num) {
		OaLeaveView view = new OaLeaveView();
		try {
			view.setVcId(rs.getString("VC_ID"));
			view.setProcessInstanceId(rs.getString("PROCESS_INSTANCE_ID"));
			view.setUserId(rs.getString("USER_ID"));
			view.setStartTime(rs.getTimestamp("START_TIME"));
			view.setEndTime(rs.getTimestamp("END_TIME"));
			view.setLeaveType(rs.getString("LEAVE_TYPE"));
			view.setReason(rs.getString("REASON"));
			view.setApplyTime(rs.getDate("APPLY_TIME"));
			view.setRealityStartTime(rs.getTimestamp("REALITY_START_TIME"));
			view.setRealityEndTime(rs.getTimestamp("REALITY_END_TIME"));
			view.setUserName(rs.getString("USER_NAME"));
			view.setStatus(rs.getInt("STATUS"));
			view.setStatusInfo(rs.getString("STATUS_INFO"));
			view.setVcDelFlag(rs.getInt("VC_DEL$FLAG"));	
		} catch (SQLException e) {	
			e.printStackTrace();
		}
		return view;
	}
	
	public ISQLMapper getSQLMapper() {
		return this;
	}
	
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getInTaskIds() {
		return InTaskIds;
	}

	public void setInTaskIds(String inTaskIds) {
		InTaskIds = inTaskIds;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}


}

